unit MainFrm;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, cxGraphics, cxControls, cxLookAndFeels,
  cxLookAndFeelPainters, dxRibbonSkins, dxSkinsCore, dxSkinsDefaultPainters,
  dxSkinsdxBarPainter, dxBar, dxStatusBar, dxRibbonStatusBar, cxClasses,
  dxRibbon, Vcl.ImgList, cxPropertiesStore;

type
  TMainForm = class(TForm)
    rbn1Tab1: TdxRibbonTab;
    rbn1: TdxRibbon;
    rbst1: TdxRibbonStatusBar;
    bar1: TdxBarManager;
    br_main: TdxBar;
    br_Dez: TdxBar;
    br_Rezident: TdxBar;
    ribt_Projects: TdxRibbonTab;
    br_Bottom: TdxBar;
    btn_BaseConfigForm: TdxBarButton;
    btn_LogErrorForm: TdxBarButton;
    btn_UpdateAppForm: TdxBarButton;
    il1: TcxImageList;
    prop1: TcxPropertiesStore;
    btn_PluginListForm: TdxBarButton;
    procedure bar1ClickItem(Sender: TdxBarManager; ClickedItem: TdxBarItem);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    procedure Click(Sender: TObject);
    procedure EventsButton;
    procedure ShowBaseForm;
  public
    { Public declarations }
  end;

var
  MainForm: TMainForm;

implementation

{$R *.dfm}

uses BaseConfigFrm, LogErrorFrm, UpdateAppFrm, AdmUtils;

procedure TMainForm.EventsButton;
var
  i :Integer;
begin
  for I := 0 to MainForm.ComponentCount - 1 do
  begin
    if Components[i].ClassType=TdxBarButton then
    begin
      {if (Components[i] as TdxBarButton).Name='btn_filtr' then
          (Components[i] as TdxBarButton).OnClick:= ShowFilter else
      if (Components[i] as TdxBarButton).Name='btn_grp' then
          (Components[i] as TdxBarButton).OnClick:= ShowGroup else
      if (Components[i] as TdxBarButton).Name='btn_excel_bar' then
          (Components[i] as TdxBarButton).OnClick:= GlobalExpExcel else
      if (Components[i] as TdxBarButton).Name='btn_UNFORESEENForm' then
          (Components[i] as TdxBarButton).OnClick:= SetUnSum else}
      (Components[i] as TdxBarButton).OnClick:= CLick;
    end;
  end;
end;

procedure TMainForm.FormCreate(Sender: TObject);
begin
  EventsButton;
  FFunc.LoadForm(prop1,Self.Name);
end;

procedure TMainForm.ShowBaseForm;
var
  F :TBaseConfigForm;
begin
  F:=TBaseConfigForm.Create(Application);
  try
    F.ShowModal;
  finally
    F.Free;
  end;
end;

procedure TMainForm.Click(Sender: TObject);
var
  i :integer;
  FName :string;
begin
  FName:=adm.GetWord((Sender as TdxBarButton).Name,2,'_');
  if FFunc.FindChild(FName) <> nil then
  begin
     for I := 0 to br_Bottom.ItemLinks.AvailableItemCount - 1 do
     begin
       if br_Bottom.ItemLinks.Items[i].Item.Description=FName then
        (br_Bottom.ItemLinks.Items[i].Item as TdxBarButton).Lowered:=true
       else
         (br_Bottom.ItemLinks.Items[i].Item as TdxBarButton).Lowered:=False;
     end;
     //Exit;
  end;
  {if (Sender as TdxBarButton).Name='btn_POActSmetaForm' then ShowPOActSmeta else
  if (Sender as TdxBarButton).Name='btn_SmetaABSForm' then ShowSmetaABSForm else}
  if (Sender as TdxBarButton).Name='btn_BaseConfigForm' then ShowBaseForm else
  FFunc.CreateForm(FName);
end;

procedure TMainForm.bar1ClickItem(Sender: TdxBarManager;
  ClickedItem: TdxBarItem);
var
  i :Integer;
begin
 if FFunc.FindChild(ClickedItem.Description)<>nil then
 begin
     for I := 0 to br_Bottom.ItemLinks.AvailableItemCount - 1 do
     begin
       (br_Bottom.ItemLinks.Items[i].Item as TdxBarButton).Lowered:=False;
     end;
   FFunc.FindChild(ClickedItem.Description).BringToFront;
  (ClickedItem as TdxBarButton).Lowered:=True;
 end;
end;

//initialization
  //ReportMemoryLeaksOnShutdown := True;

end.
